package icu.cocoon.work.controller;


import icu.cocoon.dao.base.BaseController;
import icu.cocoon.dao.base.Resp;
import icu.cocoon.system.entity.User;
import icu.cocoon.system.service.SecurityService;
import icu.cocoon.work.entity.TestReport;
import icu.cocoon.work.service.TestReportService;
import io.jsonwebtoken.lang.Assert;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Cocoon
 * @since 2020-07-02
 */
@RestController
@RequestMapping("/work/testReport")
public class TestReportController extends BaseController<TestReport, TestReportService> {

  @Resource
  private SecurityService securityService;

  @Override
  public Resp<TestReport> create(@RequestBody TestReport model) {
    User user = securityService.getCurrentUser();
    Assert.notNull(user, "无法获取当前用户");
    model.setCreateUserId(user.getId());
    return super.create(model);
  }
}

